package com.ddone.encoder;

import com.ddone.util.MD5Util;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

/**
 * @author ddone
 * @date 2024/3/31-18:51
 * md5 加密器
 */
@Component
public class Md5PasswordEncoder implements PasswordEncoder {
    // 名文加密 rawPassword(原始密码)
    @Override
    public String encode(CharSequence rawPassword) {
        return MD5Util.encrypt(rawPassword.toString());
    }

    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        return encode(rawPassword).equals(encodedPassword);
    }
}
